/*LICENSE_BEGIN
 * ******************************************************************
 * All original parts of SoccerScope2003 have copyright (2003) by
 * Team YowAI, represented by Mr. Shuhei Shiota
 * The Department of Creative Informatics
 * The Graduate School of Information Science and Technology
 * The University of Tokyo
 * 
 * Additional classes (except libraries in /lib) were developed by 
 * the Dainamite Robocup-Team of the DAI-Labor, TU-Berlin 
 * (www.dai-labor.de)
 * 
 * Extended/new classes/packages are:
 *   soccerscope.analyzer.LogfileAnalyzer
 *   soccerscope.daistatistic.*
 *   soccerscope.daistatistic.charts.*
 *   soccerscope.daistatistic.tools.*
 *   soccerscope.db.*
 *   soccerscope.dialog.*
 *   soccerscope.model.PlayerWorldModel
 *   soccerscope.model.SimplePlayer
 *   soccerscope.net.AgentConnector
 *   soccerscope.training.*
 *   soccerscope.training.conditions.*
 * ******************************************************************
LICENSE_END*/
package soccerscope.view;

import java.awt.event.ActionEvent;

import javax.swing.JTextField;

/**
 * Allows to jump to a concrete Cycle number.
 */
public class CycleNumberJumper extends AbstractSceneJumper {

    private static final long serialVersionUID = -6640906520407436537L;

    /** InputField to enter the cycle number. */
    private JTextField timeField;

    /**
     * Creates a new Button and TextField for choose and jump to cycle
     * @param scenePlayer the ScenePlayer to jump to the cycle
     */
    public CycleNumberJumper(ScenePlayer scenePlayer) {
        super(scenePlayer);
        timeField = new JTextField("0", 5);
        add(timeField);
    }
    
    /**
     * is called when the jump button was pressed. Jumps to the scene which number is
     * written in timeField
     */
    public void actionPerformed(ActionEvent arg0) {
        int number;
        try {
            number = Integer.parseInt(timeField.getText());
        } catch (NumberFormatException e) {
            return;
        }
        jumpToCycle(number);
    }

}
